﻿@using KMF.Common
@using KMF.WebUI.CustomHelpers
@using KMF.WebUI
@model ViewProductDetailDto
@{
    ViewBag.Title = string.IsNullOrEmpty(Model.MetaTitle) ? Model.Name : Model.MetaTitle;
    ViewBag.Description = string.IsNullOrEmpty(Model.MetaDescription) ? Model.Name : Model.MetaDescription;
    ViewBag.keywords = string.IsNullOrEmpty(Model.MetaKeyword) ? Model.Name : Model.MetaKeyword;
    Layout = "~/Views/Shared/_LayoutHideCate.cshtml";
    var fbFanUrl = KMF.WebUI.CustomHelpers.FunctionHelpers.returnConfig("FacebookFanpageUrl");
    var fbcode = KMF.WebUI.CustomHelpers.FunctionHelpers.returnConfig("FacebookCode");
    //var url = FunctionHelpers.GetFullUrl();
    var sizeList = (List<ProductSizeListByPidDto>)ViewBag.SizeList;
    var colorList = ((IEnumerable<ProductImageHasColorInfoDto>)ViewBag.ColorList).Select(i => new { i.ColorId, i.ColorName, i.Code })
                    .Distinct()
                    .Where(i => !i.ColorId.Equals("-1"))
                    .ToList();
    var itemColMultiple = colorList.Select(i => new { i.ColorId, i.ColorName, i.Code }).FirstOrDefault(i => i.ColorId.Equals("0"));
    var productStatus = string.Empty;
    switch (Model.ProductStatus)
    {
        case "conhang":
            productStatus = "<span class='haspd'>Còn hàng</span>";
            break;
        case "goihang":
            productStatus = "<span class='callpd'>Gọi hàng</span>"; break;
        case "hethang":
            productStatus = "<span class='overpd'>Hết hàng</span>"; break;
        case "onlyOnline":
            productStatus = "<span class='onlyOlpd'>Chỉ bán Online</span>"; break;
        default:
            productStatus = "<span class='haspd'>Còn hàng</span>";
            break;
    }
}


            <div class="p-detail-top-left">
                    <div class="breadcrum">
                        <a href="@Url.Action("Index", "Home", new {})l">Trang chủ </a>> <a href="@Url.Action("Index", "CategoryL1", new {})">Sản phẩm</a>><a href="@Url.Action("ProductByCateL2", "CategoryL1", new { cateId = Model.Id, catefil = "OEJHY",cateName = "" })"> @ViewBag.CateName</a>><a href="@Url.Action("Index", "ProductDetail", new { productId = Model.Id,productName = Model.Name })"> @Model.Name</a>
                    </div>
                @using (Html.BeginForm("Index", "ProductDetail", FormMethod.Post))
                {
                    <div class="pDetailPadding20">
                        <div class="pDetail-header">
                            <h1>@Model.Name</h1>
                            <div class="pd-social-like">
                                <ul class="socialShare ul clearfix">
                                    <li>
                                        <div id="fb-root"></div>
                                        <div class="fb-like" data-href="@fbFanUrl" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
                                    </li>
                                    <li>
                                        <g:plusone size="medium" annotation="none"></g:plusone>
                                    </li>
                                    <li></li>
                                </ul>
                            </div>
                        </div>
                        <div class="pDetail-info clearfix">
                            <div class="pDetail-img fl">
                                <!--PRODUCT DETAIL IMG-->
                                @{
                    var ListimgName = Model.ImagePath.Split('/');
                    var imgName = ListimgName[ListimgName.Length - 1];
                    var pathName = "";
                    for (int i = 0; i < ListimgName.Length - 1; i++)
                    {
                        pathName += "/" + ListimgName[i];
                    }
                                }
                                @Html.Action("ProductImageDetail", "ProductDetail", new { productId = Model.Id, ColorId = "", ProductImagePathFirst = pathName, ProductImageNameFirst = imgName })
                                <!--END PRODUCT DETAIL IMG-->
                            </div>
                            <div class="pDetail-infotext fl">
                                <div class="infotextRightTop clearfix">
                                    <div class="summary">
                                        @Html.Label("Summary",Model.Summary)
                                    </div>
                                    <div class="infotext-left fl">


                                        <p>
                                            Mã Hàng :
                                            @Html.Hidden("productId", Model.Id)
                                            @Html.Hidden("productIdRoot", Model.Id)
                                            @Html.Hidden("productImagePath", Model.ImagePath)
                                            @Html.Hidden("rootPriceProduct", Model.Price)
                                            @Html.Hidden("promotionPrice", Model.PromotionPrice)
                                            <input type="hidden" name="productName" id="productName" value="@Model.Name" />
                                            @Html.Hidden("productBarcode", Model.Barcode)
                                            @Html.Hidden("productStatus", Model.ProductStatus)
                                            @Html.Hidden("productColor")
                                            @Html.Hidden("productColorCode")
                                            @Html.Hidden("productSizeId")
                                            @Html.Hidden("productSizeName")
                                            @Html.Hidden("productSizePrice")
                                            @Html.Hidden("promotionPercent", Model.DiscountPercentage)
                                            @Html.Hidden("decreasePrice", Model.DiscountAmount)
                                            @Html.Hidden("providerName", Model.ProviderName)
                                            @Html.Hidden("categoryId", Model.CategoryId)
                                            @Html.Hidden("categoryName", Model.CategoryName)

                                        </p>
                                        
                                        @if (Model.PromotionPrice > 0)
                                        {
                                            <p class="pd-priceLast">
                                                Giá :
                                            </p>
                                        }
                                        else
                                        {
                                            <p>
                                                Giá :
                                            </p>
                                        }

                                        <p>
                                            Tình Trạng :
                                        </p>
                                        @if (sizeList.Any())
                                        {
                                            <p>
                                                Size :
                                            </p>
                                        }
                                        @if (colorList.Any())
                                        {
                                            <p>
                                                Màu sắc :
                                            </p>
                                        }
@*                                        <p>
                                            Đánh Giá :
                                        </p>*@
                                        <p class="pd-quan">
                                            Số Lượng :
                                        </p>
                                    </div>
                                    <div class="infotext-right fl">
                                        <p class="pd-code">
                                            @Model.Barcode
                                        </p>
                                       
                                        @if (Model.PromotionPrice > 0)
                                        {
                                            <div class="pd-price">
                                                <span class="pd-curent-price">@Model.PromotionPrice.ToString("#,###")</span> đ
                                                <p class="p-price-promo">Giá trước đây <span class="p-priceOld">@Model.Price.ToString("#,###") đ</span> , Tiết kiệm <b>@Model.DiscountPercentage.ToString("##")%</b></p>
                                            </div>
                                        }
                                        else
                                        {
                                            <p class="pd-price">
                                                @Model.Price.ToString("#,###") đ
                                            </p>
                                        }

                                        <p class="pd-sttus">
                                            @Html.Raw(productStatus)
                                        </p>
                                        @if (sizeList.Any())
                                        {
                                            var itemFirstSize = sizeList.FirstOrDefault();
                                            <p class="pd-size clearfix">
                                                @if (itemFirstSize != null)
                                                {
                                                    var sizePromotionPrice = Model.GetPricePromotionBySizePrice(itemFirstSize.SizePrice);
                                                    <a href="javascript:void(0);" rel="nofollow" title="@itemFirstSize.SizeName" sizepromotionpriceshow="@sizePromotionPrice.ToString("#,###")" sizepriceshow="@itemFirstSize.SizePrice.ToString("#,###")" sizepromotionprice="@sizePromotionPrice" sizeid="@itemFirstSize.SizeId" sizeprice="@itemFirstSize.SizePrice">@itemFirstSize.Code</a>
                                                }
                                                @foreach (var item in sizeList.Where(item => item != sizeList.First()))
                                                {
                                                    var sizePromotionPrice = Model.GetPricePromotionBySizePrice(item.SizePrice);
                                                    <a href="javascript:void(0);" rel="nofollow" title="@item.SizeName" sizepromotionpriceshow="@sizePromotionPrice.ToString("#,###")" sizepriceshow="@item.SizePrice.ToString("#,###")" sizepromotionprice="@sizePromotionPrice" sizeid="@item.SizeId" sizeprice="@item.SizePrice">@item.Code</a>
                                                }
                                            </p>
                                        }
                                        @if (colorList.Any())
                                        {
                                            <p class="pd-Color clearfix">
                                                @if (itemColMultiple != null)
                                                {
                                                    <a href="javascript:void(0);" rel="nofollow" style="background-color: @itemColMultiple.Code;" colorcode="@itemColMultiple.Code" colorname="@itemColMultiple.ColorName" id="color-id-@itemColMultiple.ColorId" title="@itemColMultiple.ColorName">
                                                    </a>
                                                }

                                                @foreach (var item in colorList.Where(item => !item.ColorId.Equals("0")))
                                                {
                                                    <a href="javascript:void(0);" rel="nofollow" style="background-color: @item.Code;" colorcode="@item.Code" colorname="@item.ColorName" id="color-id-@item.ColorId" idcolor="@item.ColorId" title="@item.ColorName">
                                                    </a>
                                                }
                                            </p>
                                        }
@*                                        <div style="line-height: 13px; margin: 5px 0px;">
                                            @{
                                                string StarPercent = "0";
                                                if (Model.AverageRate > 0)
                                                {
                                                    StarPercent = (Convert.ToDouble(Model.AverageRate) * 100 / 5).ToString("#.#").Replace(',', '.');
                                                }
                                            }
                                            <span class="itm-ratStars inlineBlocka"><span style="width: @StarPercent%;" class="itm-ratStars itm-ratRating"></span></span>
                                        </div>*@
                                        <div class="box-quan">
                                            <input type="text" maxlength="2" value="1" name="productQuantity" id="productQuantity" />
                                            <a href="javascript:void(0);" class="quan-top" rel="nofollow"></a>
                                            <a href="javascript:void(0);" class="quan-bottom" rel="nofollow"></a>
                                            
                                        </div>
                                        <div class="img-cart"></div>
                                    </div>
                                </div>
                                <div class="infotextRightBottom">
                                    <div class="pd-detailproperty">
                                        <ul class="tab-property ul">
                                            @if (!string.IsNullOrEmpty(Model.CustomInfoFirst))
                                            {
                                                <li>
                                                    <span>@Model.CustomInfoFirst</span>
                                                </li>
                                            }
                                            @if (!string.IsNullOrEmpty(Model.CustomInfoSecond))
                                            {
                                                <li>
                                                    <span>@Model.CustomInfoSecond</span>
                                                </li>
                                            }
                                            @if (!string.IsNullOrEmpty(Model.CustomInfoThird))
                                            {
                                                <li>
                                                    <span>@Model.CustomInfoThird</span>
                                                </li>
                                            }

                                        </ul>
                                    </div>
                                 
                                    <div class="pd-detail clearfix">
                                        @if (!Model.ProductStatus.Equals("hethang"))
                                        {
                                            <input type="submit" class="btnGioHang fl" />
                                        }

                                    </div>  
                                     
                                </div>
                            </div>
                        </div>
                    </div>
                }
            </div>

                <div class="concern fl">
                    @Html.Action("SlideProductConcern", new { categoryId = ViewBag.CateId, ProductDate = Model.CreateDate, ProductId = Model.Id })
                </div>


@section scripts
{
    <link href="~/Scripts/CloudZoom/cloud-zoom.css" rel="stylesheet" />
    @if (!string.IsNullOrEmpty(fbFanUrl) && !string.IsNullOrEmpty(fbcode))
    {
        @Html.Raw(Server.HtmlDecode(fbcode))
    }
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/productDetail")
    @Scripts.Render("~/bundles/bxSlide")
    @Styles.Render("~/Content/bxSlide")
<script type="text/javascript">
        var currentPage = "product";
    </script>
}

@section headerProperty
{
    <meta property="og:image" content="@Model.ImagePath.ImagePathThumbDefault()" itemprop="thumbnailUrl" />
    <meta property="og:title" content="@Model.Name">
    <meta itemprop="description" property="og:description" content="@Model.MetaDescription">
    <meta property="og:url" content="@Request.Url" />
}